<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="UTF-8">
	<title>抵扣卡列表</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    
<!-- 最新导入 -->
<script type="text/javascript" src="<c:url value='/template/new_muban/js/jquery-min-1.7.js'/>"></script>
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/font.css'/>">
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/xadmin.css'/>">   
<script src="<c:url value='/template/new_muban/lib/layui/layui.js'/>" charset="utf-8"></script> 
<script type="text/javascript" src="<c:url value='/template/new_muban/js/xadmin.js'/>"></script>

 <!-- 富文本编辑器 -->
<script type="text/javascript" charset="utf-8" src="<c:url value='/ue/ueditor.config.js'/>"></script>
<script type="text/javascript" charset="utf-8" src="<c:url value='/ue/ueditor.all.js'/>"> </script>



<!-- 标签 -->
<link rel="stylesheet" type="text/css" href="<c:url value='/template/lead_into/tags_input/css.css'/>" />
<script src="<c:url value='/template/lead_into/tags_input/tagsinput.js'/>" type="text/javascript" charset="utf-8"></script>
		
<style type="text/css">
	/*圆形头像  */
	/* #divcss5{ margin:10px auto}  */
	#divcss5 img{ border-radius:50%} 
	.x-so input.layui-input {
    	width: 150px;
	}
</style>
</head>
<body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">优惠券管理</a>
        <a>
          <cite>优惠券列表</cite></a>
      </span>
     <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
	            <div class="layui-row layui-col-space15">
	                <div class="layui-col-md12">
	                    <div class="layui-card">
            <div class="layui-card-body "><!-- onsubmit="return verifyDate();" -->
                             
                        </div> 
       <div class="layui-card-header">
        <!-- <a class="layui-btn" href=""><i class="layui-icon"></i></a> -->
     	 <button class="layui-btn" onclick="xadmin.open('添加抵扣卡','<c:url value='/toAddSmallticket.do'/>')"><i class="layui-icon"></i>添加抵扣卡</button>
     </div> 
      <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form" id="">
            <!-- <table id="dataTable" class="am-table am-table-striped am-table-hover table-main"> -->
              <thead>
              <tr>
                <th>折扣卡标题</th><th>创建时间</th><th>失效时间</th><!-- <th >数量</th><th>销量</th><th>创建时间</th> --><th class="table-set">操作</th>
              </tr>
              </thead>
              <tbody>
              <c:forEach items="${smallticketList}" var="data">
              	<tr>
              		<td>${data.ct_name}</td>
              		<%-- <td><img width="100px" height="100px" src="${data.thumb}"> </td> --%>
              		<%-- <td>${data.a_state}</td> --%>
              		<%-- <td >${data.starttime}</td> --%>
              		<td>${data.ct_time}</td>
              		<td>${data.ct_Invalidtime}</td>
              		<td style="text-align: center;">
                  		<div class="layui-btn-group">
                    			<%-- <a href="selectThisArticle.do?a_id=${data.a_id}&type=1"  class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span>详情</a> --%>
                      			<%-- <a href="updateMyArticle.do?a_id=${data.a_id}" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>&nbsp;&nbsp;&nbsp;&nbsp; --%>


                      			 <a class="layui-btn layui-btn-sm" title="编辑"  href="updateThisSmallticketbefore.do?ct_id=${data.ct_id}"><span>编辑</span></a>

                      			 <%-- <a class="layui-btn layui-btn-sm" title="编辑" href="updateThisActivitybefore.do?id=${data.id}" ><i class="layui-icon">&#xe642;</i></a> --%>


                      			<%--  <button class="layui-btn layui-btn-sm" title="编辑"  onclick="x_admin_show('编辑折扣卡','<c:url value='/updateThisActivitybefore.do?id=${data.id}'/>')"><span>编辑</span></button> --%>

                      	

                      			<!-- <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span> 复制</button> -->
                      			<button onclick="deleteThis(${data.ct_id})" title="删除"  class="layui-btn layui-btn-sm layui-btn-danger"><span>删除</span></button>
                    			
                 		</div>
                	</td>
              	</tr>
              	
              </c:forEach>
           
              </tbody>
            </table>
            </div>
            <div class="pagin">
            共 ${count} 条记录
        <c:choose>
		<c:when test="${page != 1}">
		<a href="findAllSmallticket.do?page=${page-1}"><input type="button" name="lastPage" value="上一页" /></a>
		</c:when>
		<c:otherwise>
		<input type="button" disabled="true" name="lastPage" value="上一页" /><!-- 为了要那个灰掉的button -->
		</c:otherwise>
		</c:choose>

		<!-- 页数列表 -->
		<c:forEach items="${pageList}" var="item">
		<c:choose>
		<c:when test="${item == page}">
		<a href="findAllSmallticket.do?page=${item}" class="currentPage">${page}</a>
		</c:when>
		<c:otherwise>
		<a href="findAllSmallticket.do?page=${item}">${item}</a>
		</c:otherwise>
		</c:choose>
		</c:forEach>

		<!-- 下一页 按钮 -->
		<c:choose>
		<c:when test="${page != pageNum}">
		<a href="findAllSmallticket.do?page=${page+1}">
		<input type="button" name="nextPage" value="下一页" />
		</a>
		</c:when>
		<c:otherwise>
		<input type="button" disabled="true" name="nextPage" value="下一页" />
		</c:otherwise>
		</c:choose>
		</div>
           </div>
  </div>   
            <hr />
            
    <!--  </form> -->
          </div>
  </div>
    <script>
  //删除点击事件
    function deleteThis(data){
    	//alert(data);
		 if(confirm("确定要删除数据吗？")){
			 //alert("进入删除")
			  }
			  else{
			  // alert("点击了取消按钮");
			   return false;
		  }
		  $.ajax({
				url : "deleteSmallticket.do",  //sale
		        async : false, // 注意此处需要yi步  
		        type : "POST",
		        data:{"ct_id":data},
		        success : function(SuccessOrFail) {
		        	//alert(SuccessOrFail);
		        	//1为成功0为事变
		        	if(SuccessOrFail == 1){
		        		alert("删除成功");
		         		window.location.href = 'findAllSmallticket.do?page=1';
		        	}else if (SuccessOrFail == 0) {
						alert("该折扣卡与正在进行的促销活动绑定,不可删除！");
					}else{
		        		alert("删除失败");
		        	}
		        }
 			}); 
		 }
   
   /*  
    layui.use('layer', function(){
        layer.msg('已删除!',{icon:1,time:10000},function(){
	parent.location.reload();
	let liId = $.cookie('liId');
	let liClass = $.cookie('liClass');
	console.log(liId);
	console.log(liClass);
	$('liId').attr("class","layui-nav-item layui-nav-iteme");
	console.log($(liId).attr("class"));
        	
        });  
    	
    });   */ 
    //时间
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认要停用吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              
          });
      }

      /*用户-开通取消操作*/
      function member_stop_caozuo(obj,id){
              if($(obj).attr('title')=='停用'){
		          layer.confirm('确认要停用吗？',function(index){
	                //发异步把用户状态进行更改
	                $(obj).attr('title','开通')
	                $(obj).find('i').html('&#xe62f;');
	                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('未开通');
	                layer.msg('已停用!',{icon: 5,time:1000});
	                
	                
	                
	          	});
              }else{
            	 layer.confirm('确认要开通吗？',function(index){
	                $(obj).attr('title','停用')
	                $(obj).find('i').html('&#xe601;');
	                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已开通');
	                layer.msg('已开通!',{icon: 6,time:1000});
              	});
              }
      }

      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              //发异步删除数据
              $(obj).parents("tr").remove();
              layer.msg('已删除!',{icon:1,time:1000});
          });
      }



      function delAll (argument) {

        var data = tableCheck.getData();
  
        layer.confirm('确认要删除吗？'+data,function(index){
        
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
      }
    </script>

     
     <!-- 1 绿√  2 红X  3 黄?  4  灰锁  5  红哭脸  6 绿笑脸 7 黄!  --> 
    <!-- //页面跳转 -->
<script type="text/javascript">
	function checkNum(sumNumber,start,end,s_name,s_contact,s_phone,openid,pay_status,page_num,tuijian_contact){
		var num = $(".inputNum").val();
		//alert(sumNumber+"/"+num+"/"+s_name+"/"+s_contact+"/"+s_phone+"/"+openid+"/"+pay_status+"/"+start+"/"+end+"/"+page_num );
		if(!isNaN(num)){      
			//alert("是数字类型!");
			if (num>sumNumber) {
				alert("超出查询范围");
				layer.alert('超出查询范围!!',{icon:2,time:2000});
				return false;
			} else if (num<1) {
				alert("请输入正确的页码");
				layer.alert('请输入正确的页码!',{icon:2,time:2000});
				return false;
			} else {
		 		window.location.href = "<c:url value='/findAllShopUser.do?s_name="+s_name+"&s_contact="+s_contact+"&s_phone="+s_phone+"&number="+num+"&openid="+openid+"&pay_status="+pay_status+"&start="+start+"&end="+end+"&page_num="+page_num+"&tuijian_contact="+tuijian_contact+"'/>";
			}
		}else{      
			alert("不是数字类型!");
			layer.alert('不是数字类型!',{icon:2,time:2000});
			return false;
		}
	}
/*
 * 验证 查询时间大小 
 */	
 function verifyDate() {
	var start = $("#start").val();
	var end = $("#end").val();
	//alert(start > end);
	if(start > end){
		//alert("开始日期不能大于结束日期!");
		layer.alert('开始日期不能大于结束日期!',{icon:2,time:3000});
		return false;		
	}
}
</script>      
      
  </body>
</html>